package engine.j2d;


public class SFont
{
	private Image font;
	private Image sFont[] = new Image [ 256 ] ;
	private static int charWidth;
	private static int charHeight;
	public SFont(String ref)
	{
		font= new Image(ref);
		biuldFont();
	}
	private void biuldFont()
	{
		int xi = font.getWidth() / 16;
		int yi = font.getHeight() / 16;
		int z = -1;
		for (int i = 0; i < 16; i++)
			for (int j = 0; j < 16; j++)
			{
				z++;
				if (z < 256)
				{
					sFont[z] = font.getSubImage(j * xi, i * yi, xi, yi);
				}
			}
		charWidth=sFont[0].getWidth();
		charHeight=sFont[0].getHeight();
	}
	public static int getCharWidth()
	{
		return charWidth;
	}
	public static int getCharHeight()
	{
		return charHeight;
	}
	public void drawString(String text, float xpos,float ypos,Color color)
	{
		for(int i=0;i<text.length();i++)
		{
			sFont[text.codePointAt(i)].draw(xpos+10*i, ypos,color);
		}	
	}	
}
